<!DOCTYPE html >
<html style="height: 100%; padding: 0px; margin: 0px; background-color: #000000;">
  <!-- This file exists because even the modern Qt web browser implementation
  doesn't give us an easy way to send and receive Web "messages". But they do
  let us run JavaScript, so that's what we do. We (ab)use the console log
  message processing hooks to be able to notify the Python when messages from
  the app arrive. -->

  <head>
    <meta charset="utf-8" http-equiv="X-UA-Compatible" content="chrome=1, IE=edge"/>
    <title>WWT Qt Wrapper</title>
    <style type="text/css">
      body, html {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        overflow: hidden;
      }

      iframe {
        border: none;
        margin: 0;
        padding: 0;
        width: 100vw;
        height: 100vh;
      }
    </style>
  </head>
  <body>
    <iframe id="wwt"></iframe>

    <script type="text/javascript">
      // If you want to hack this file to use a different source for the
      // research app (e.g., a localhost server on another port to test out
      // changes), edit the `iframe.src` line, the origin on `postMessage` line,
      // and the origin in the event-listener origin test `if` statement.

      var iframe = document.getElementById("wwt");
      iframe.src = "research/?origin=" + location.origin;

      function pywwtSendMessage(payload) {
        var window = iframe.contentWindow;
        if (window) {
          window.postMessage(payload, location.origin);
        }
      }

      window.addEventListener(
        'message',
        function (event) {
          var payload = event.data;

          if (event.origin !== location.origin)
            return;

          console.log("pywwtMessage:" + JSON.stringify(payload));
        },
        false
      );
    </script>
  </body>
</html>
